package net.learn.system.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import net.learn.framework.common.constant.Constant;
import net.learn.framework.common.utils.Result;
import net.learn.system.enums.LoginOperationEnum;
import net.learn.system.service.SysLogLoginService;
import net.learn.system.vo.SysIndexVO;
import net.learn.system.vo.SysTokenVO;
import org.springframework.web.bind.annotation.*;

/**
 * 首页
 *
 * @author lilizhi 762966800@qq.com
 */
@RestController
@RequestMapping("sys/index")
@Tag(name = "首页管理")
@AllArgsConstructor
public class IndexController {

    private SysLogLoginService sysLogLoginService;

    @PostMapping("savelog")
    @Operation(summary = "日志记录")
    public Result<SysTokenVO> login(@RequestBody SysIndexVO login) {
        sysLogLoginService.save(login.getUsername(),login.getOrgId(), Constant.SUCCESS, LoginOperationEnum.LOGIN_SUCCESS.getValue());

        return Result.ok("success");
    }
    @GetMapping("/")
    public String index() {
        return "您好，项目已启动，祝您使用愉快！";
    }
}
